/*
 * mining.h
 *
 *  Created on: Mar 24, 2011
 *      Author: cookiemouse
 */

#ifndef MINING_H_
#define MINING_H_
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
//global function
using namespace std;


struct TIListNode
{
	int						TIDIndex;
	int						Timestamp;
	int						Mark;
};


class TIList
{
	friend class ReferenceSpace;

public:
	vector< TIListNode >	List;                                         //a vector which container all the TIListNode
    int						numberofnode;	                              //The unit TID in the TIList donated as support
	int						cmark;

	TIList();                                                             //constructor
	~TIList();                                                            //destructor

	void					insert(TIListNode NewNode);
    void					insert(int tidindex, int time, int cmark);
    void					insert(TIListNode* pTIListNode);
    void					clear();
	bool					empty();
	int						size();
	TIListNode*				at(int index);
	TIListNode*				back();

};

struct Location
{
	int x;
	int y;
};

struct TIHeader                                                          //TIList headerLink, used in the reference to link into the list
{
	Location	coordinate;
	TIList*		HeadPtr;
    bool		frequent;
};

class ReferenceSpace                                                     //Reference space
{
public:
	vector< string >				TIDVector;							  //store the TID
	vector < string >				patterns;			                  // add the pattern in this and then wrtie it to the file
	vector< vector< TIHeader > >	space;	                              // the reference space instance which map all the transaction in its_
	stack <string> mypattern;
	//variable
	int								length;                               //the length of the reference space
	int								Max_TimeSpan;                         //the input maximum time span
	int								Min_Support;                          //the input minimum support
	int								numberofP;                            //the number of pattern that mined
	string							filename;                             //the output file name
	string							pattern;                              //a part of pattern
    //							pattern2print;                             //a full length pattern
	ofstream ResultFile;                                                  //the output file stream during mining

	int tuplesScanned;
	int candidates;
	int  candidatesarry [4];


	ReferenceSpace(int K, int MTS, int MS);	                              //constrcutor
	~ReferenceSpace();		                                              //deconstrctor

    vector< TIList* > Intersection(TIList* TIListA, TIList* TIListB);     //find the same items in the two sequence
	void DFS(int x, int y, TIList* InterTIList);                          //traverse in the reference space
};

#endif /* MINING_H_ */
